package com.jcl.recruit.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.resume.mapper.ResumeEduMapper;
import com.jcl.recruit.resume.model.ResumeEdu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ResumeEduLogic
 * @Description TODO
 * @Author yyliu
 * @Date 2018/10/31 11:21
 * @Version 1.0
 **/
@Component
public class ResumeEduLogic implements ResumeEduMapper {

    @Autowired
    private ResumeEduMapper resumeEduMapper;

    public Map<Integer, List<ResumeEdu>> findListByResumeMap(String corpCode, List<Integer> resumeIds) {

        Map<Integer, List<ResumeEdu>> dataMap = new HashMap<>();
        List<ResumeEdu> list = resumeEduMapper.findListByResumeIds(corpCode, resumeIds);
        if (CollectionUtils.isNotEmpty(list)) {
            for (ResumeEdu entity : list) {
                List<ResumeEdu> entityList = dataMap.get(entity.getResumeId());
                if (null == entityList) {
                    entityList = new ArrayList<>();
                    dataMap.put(entity.getResumeId(), entityList);
                }
                entityList.add(entity);
            }
        }
        return dataMap;
    }

    @Override
    public List<ResumeEdu> findListByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumeEduMapper.findListByResumeIds(corpCode, resumeIds);
    }

    @Override
    public List<ResumeEdu> findListByResumeId(String corpCode, Integer resumeId) {
        return resumeEduMapper.findListByResumeId(corpCode, resumeId);
    }

    @Override
    public List<Map<String, Object>> findObjListByResumeId(String corpCode, Integer resumeId) {
        return resumeEduMapper.findObjListByResumeId(corpCode, resumeId);
    }

    @Override
    public int isExitEntity(ResumeEdu entity) {
        return resumeEduMapper.isExitEntity(entity);
    }

    @Override
    public int batchInsert(List<ResumeEdu> list) {
        return resumeEduMapper.batchInsert(list);
    }

    @Override
    public int insert(ResumeEdu entity) {
        return resumeEduMapper.insert(entity);
    }

    @Override
    public int updateByPrimaryKey(ResumeEdu entity) {
        return resumeEduMapper.updateByPrimaryKey(entity);
    }

    @Override
    public int deleteById(Integer id) {
        return resumeEduMapper.deleteById(id);
    }

    @Override
    public int batchDeleteByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumeEduMapper.batchDeleteByResumeIds(corpCode, resumeIds);
    }
}
